import { ComponentWithComputed } from 'miniprogram-computed';
import { formartDate } from '../../utils/index.js';

ComponentWithComputed({
  options: {
    styleIsolation: 'shared',
  },
  properties: {
    info: {
      type: Object,
      value: {},
    },
  },
  data: {},
  computed: {
    viewCount(data) {
      const num = data.info.view_count;
      return num > 1e3 && num < 1e4
        ? (num / 1e3).toFixed(1) + 'k'
        : num >= 1e4
        ? (num / 1e4).toFixed(1) + 'w'
        : num;
    },
    publishDate(data) {
      return formartDate(+data.info.publish_date, 5);
    },
  },
  lifetimes: {
    created() {},
    attached() {},
    moved() {},
    detached() {},
  },
  methods: {},
});
